package com.cjg.scrolldemo.adapter;

import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.view.LayoutInflaterCompat;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cjg.scrolldemo.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.cjg.scrolldemo.RecyclerViewActivity;

import java.util.List;
import java.util.function.Predicate;

public class EmptyViewAdapter<T, K extends BaseViewHolder> extends BaseQuickAdapter<T, K> {

    public EmptyViewAdapter(int layoutResId, @Nullable List<T> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(K helper, T item) {
    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    public void showLoading(Context c){
        View view = LayoutInflater.from(c).inflate(R.layout.view_loading,getRecyclerView(), false);
        setEmptyView(view);
    }

    public void showEmpty(Context c) {
        View view = LayoutInflater.from(c).inflate(R.layout.view_empty,getRecyclerView(), false);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                onRefresh();
            }
        });
        setEmptyView(view);
    }

    public void showError(Context c) {
        View view = LayoutInflater.from(c).inflate(R.layout.view_error,getRecyclerView(), false);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                onRefresh();
            }
        });
        setEmptyView(view);
    }

}
